/*/////////////////////////////////////////////////////////////////////////////////
/// An
///    ___   ____ ___ _____ ___  ____
///   / _ \ / ___|_ _|_   _/ _ \|  _ \
///  | | | | |  _ | |  | || | | | |_) |
///  | |_| | |_| || |  | || |_| |  _ <
///   \___/ \____|___| |_| \___/|_| \_\
///                              File
///
/// Copyright (c) 2008-2009 Ismail TARIM <ismail@royalspor.com> and the Ogitor Team
//
//This program is free software; you can redistribute it and/or modify it under
//the terms of the GNU Lesser General Public License as published by the Free Software
//Foundation; either version 2 of the License, or (at your option) any later
//version.
//
//This program is distributed in the hope that it will be useful, but WITHOUT
//ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
//FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
//
//You should have received a copy of the GNU Lesser General Public License along with
//this program; if not, write to the Free Software Foundation, Inc., 59 Temple
//Place - Suite 330, Boston, MA 02111-1307, USA, or go to
//http://www.gnu.org/copyleft/lesser.txt.
////////////////////////////////////////////////////////////////////////////////*/

#pragma once

namespace Ogitors
{

class OgitorExport CPlaneEditor : public CNodeEditor
{
    friend class CPlaneEditorFactory;
public:
    /// Returns the Factory associated with this object
	static CBaseEditorFactory *getFactory();
    /// Returns the Factory associated with this object can be overridden
	virtual CBaseEditorFactory *getFactoryDynamic();

    void          setNormal(const Ogre::Vector3& value, bool display);
    Ogre::Vector3 getNormal();
    void          setDistance(const Ogre::Real& value, bool display);
    Ogre::Real    getDistance();
    void          setWidth(const Ogre::Real& value, bool display);
    Ogre::Real    getWidth();
    void          setHeight(const Ogre::Real& value, bool display);
    Ogre::Real    getHeight();
    void          setXSegments(const int& value, bool display);
    int           getXSegments();
    void          setYSegments(const int& value, bool display);
    int           getYSegments();
    void          setNumCoordSets(const int& value, bool display);
    int           getNumCoordSets();
    void          setUTile(const int& value, bool display);
    int           getUTile();
    void          setVTile(const int& value, bool display);
    int           getVTile();
    void          setHasNormals(const bool& value, bool display);
    bool          getHasNormals();
    void          setMaterial(const Ogre::String& value, bool display);
    Ogre::String  getMaterial();
    void          setCastShadows(const bool& value, bool display);
    bool          getCastShadows();

    virtual void            processParameters(Ogre::NameValuePairList &params);
    /// Virtual Function that loads (Creates) underlying object 
    virtual bool            load();
    /// Virtual Function that unloads (Deletes) underlying object 
    virtual bool            unLoad();

    /// This function is called when user drops a material on the object
    virtual void            onDropMaterial(Ogre::Vector3 position, const Ogre::String& materialname);
    virtual void            getObjectProperties(Ogre::NameValuePairList &retList);
    virtual bool			setupPropertiesWnd(bool present);
    virtual void            showBoundingBox(bool bShow);
	virtual Ogre::AxisAlignedBox getAABB() {if(m_PlaneHandle) return m_PlaneHandle->getBoundingBox();else return Ogre::AxisAlignedBox::BOX_NULL;};
    /// Overridden by Editor Objects to Import Object Dependant Properties
    virtual void            restore(Ogre::NameValuePairList &retList);
    /// Gets the Handle to encapsulated object
    inline virtual void    *getHandle() {return static_cast<void*>(m_PlaneHandle);};

protected:
	Ogre::Entity *m_PlaneHandle;
    Ogre::Vector3 m_Normal;
    Ogre::Real    m_Distance;
    Ogre::Real    m_Width;
    Ogre::Real    m_Height;
    int           m_xSegments;
    int           m_ySegments;
    int           m_NumCoordSets;
    int           m_uTile;
    int           m_vTile;
    bool          m_HasNormals;
    Ogre::String  m_Material;
    bool          m_CastShadows;

	CPlaneEditor();
	virtual       ~CPlaneEditor() {};
	virtual bool  handleCustomFunction(int BIND_ID,Ogre::String val);
    Ogre::Entity *_createPlane();
};

class OgitorExport CPlaneEditorFactory: public CBaseEditorFactory
{
public:
  CPlaneEditorFactory();
  virtual ~CPlaneEditorFactory() {};
  virtual void Init();
  virtual CBaseEditor *CreateObject(CBaseEditor **parent, Ogre::NameValuePairList &params);
  virtual Ogre::String GetPlaceHolderName() {return "scbLight_Omni.mesh";};
};

}
